﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Microserve.TeleEye.BusinessServices;
using System.Collections.Generic;
using MenuBar = Microserve.TeleEye.Common.MenuBar;

namespace Microserve.TeleEye.Web
{
    public partial class Product : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            string sectionname = Page.Request.QueryString["s"];

            if (!string.IsNullOrEmpty(sectionname))
            {
                MenuController controller = new MenuController();
                List<MenuBar.MenuItem> items = controller.GetSectionMenu(HttpContext.Current,
                    sectionname);

                if (controller.ShowCommonMenu(HttpContext.Current, sectionname))
                {
                    items.AddRange(controller.GetSectionMenu(HttpContext.Current, "commonmenu"));
                }


                this.toolboxlist.Controls.Add(new LiteralControl()
                {
                    Text =
                        Utility.MenuFactory.GenerateMenu(items)
                });

                SectionManager sManager = new SectionManager();
                this.sectionContent.InnerHtml = sManager.GetSectionContent(HttpContext.Current, sectionname);

                string parentSectionText = sManager.GetSectionParentText(HttpContext.Current, sectionname);
                string parentSectionUrl = sManager.GetSectionParentUrl(HttpContext.Current, sectionname);
                string currentSectionText = sManager.GetSectionName(HttpContext.Current, sectionname);
                if (parentSectionText != null)
                {
                    if (!string.IsNullOrEmpty(parentSectionText))
                    {
                        this.parentsection.InnerHtml = parentSectionText;
                        this.parentsection.HRef = parentSectionUrl;
                        this.lblCurrentSection.Text = " > " + currentSectionText;

                        ((Main)this.Master).PageSpecificTitle = currentSectionText;
                    }
                    else
                    {
                        this.parentsection.Visible = false;
                        this.lblCurrentSection.Text = currentSectionText;
                    }
                }
            }
        }
    }
}
